﻿using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using FoodBank.Resources;

namespace FoodBank.Web.ViewModels
{
    public class RegisterViewModel
    {
        [Display(ResourceType = typeof(AccountResources), Name = "UserName")]
        [Required(ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "UserNameRequired")]
        [StringLength(100, ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "UserNameLong")]
        public string UserName { get; set; }

        [Display(ResourceType = typeof(AccountResources), Name = "Password")]
        [Required(ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "PasswordRequired")]
        [StringLength(100, ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "PasswordInvalid", MinimumLength = 6)]
        public string Password { get; set; }

        [Display(ResourceType = typeof(AccountResources), Name = "ConfirmPassword")]
        [Required(ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "ConfirmPasswordRequired")]
        [Compare("Password", ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "ConfirmPasswordCompare")]
        public string ConfirmPassword { get; set; }

        [Display(ResourceType = typeof(AccountResources), Name = "FirstName")]
        [Required(ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "FirstNameRequired")]
        [StringLength(100, ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "FirstNameLong")]
        [RegularExpression(@"^[A-Za-z]+", ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "FirstNameNonNumeric")]
        public string FirstName { get; set; }

        [Display(ResourceType = typeof(AccountResources), Name = "LastName")]
        [Required(ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "LastNameRequired")]
        [StringLength(100, ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "LastNameLong")]
        [RegularExpression(@"[A-Za-z]+", ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "LastNameNonNumeric")]
        public string LastName { get; set; }

        [Display(ResourceType = typeof(AccountResources), Name = "Email")]
        [Required(ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "EmailRequired")]
        [RegularExpression(@"[\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?", ErrorMessageResourceType = typeof(AccountResources), ErrorMessageResourceName = "EmailInvalid")]
        public string Email { get; set; }
    }
}